import asyncio
from fastmcp import Client

async def main():
    # 连接 MCP HTTP 服务器
    async with Client("http://localhost:8080/mcp") as client:
        # 调用 add 工具
        result = await client.call_tool("add", {"a": 10, "b": 20})
        print("add tool result:", result)

        # # 调用 greet 资源读取
        # welcome = await client.read_resource("welcome://version1/zh/张三")
        # print("welcome resource result:", welcome)
        #
        # # 调用提示模板 generate_code_request
        # prompt_code = await client.get_prompt("generate_code_request", {"language": "Python", "task": "计算两个数的和"})
        # print("Prompt generate_code_request result:")
        # print(prompt_code.messages)

        # 调用 获取天气 工具
        result = await client.call_tool("query_weather", {"city": "成都"})
        print("get_weather:", result)




if __name__ == "__main__":
    asyncio.run(main())
